package com.yanchangapp.factory;

import com.yanchangapp.ui.fragment.home.HomeFragment;
import com.yanchangapp.ui.fragment.home.MeFragment;
import com.yanchangapp.ui.fragment.home.WorkFragment;

public class HomeMainFactory {
    private HomeFragment mHomeFragment = null;
    private MeFragment mMeFragment = null;
    private WorkFragment mWorkFragment = null;

    private HomeMainFactory(){

    }

    public static HomeMainFactory getInstance(){
        return  HomeMainFactoryHolder.F_INSTANCE;
    }

    private static class HomeMainFactoryHolder{
        private static final HomeMainFactory F_INSTANCE = new HomeMainFactory();
    }

    public HomeFragment getHomeInstance(){
        if (mHomeFragment == null){
            synchronized (HomeMainFactory.class){
                if (mHomeFragment == null){
                    mHomeFragment = new HomeFragment();
                }
            }
        }
        return mHomeFragment;
    }

    public MeFragment getMeInstance(){
        if (mMeFragment == null){
            synchronized (HomeMainFactory.class){
                if (mMeFragment == null){
                    mMeFragment = new MeFragment();
                }
            }
        }
        return mMeFragment;
    }

    public WorkFragment getWorkInstance(){
        if (mWorkFragment == null){
            synchronized (HomeMainFactory.class){
                if (mWorkFragment == null){
                    mWorkFragment = new WorkFragment();
                }
            }
        }
        return mWorkFragment;
    }
}
